import java.io.File;
import java.io.IOException;
import java.util.Calendar;
import java.util.TimeZone;

import org.apache.commons.io.FileUtils;

import com.greensuisse.console.Consolse;

public class SyncPhoto {
	public static void main(String[] args) throws IOException {
		String destPath = "D:\\hly\\pictures";
		String sourcePath = "F:\\DCIM\\101MSDCF";
		File sourceFolder = new File(sourcePath);
		File[] sourceFiles = sourceFolder.listFiles();

		Calendar calendar = Calendar.getInstance(TimeZone.getDefault());
		destPath = destPath
				+ "\\"
				+ String.format("%4d.%02d.%02d", calendar.get(Calendar.YEAR),
						calendar.get(Calendar.MONTH),
						calendar.get(Calendar.DAY_OF_MONTH));
		File destFolder = new File(destPath);
		if (!destFolder.exists())
			destFolder.mkdir();

		for (File file : sourceFiles) {
			System.out.println(file.getAbsolutePath());
			FileUtils.copyFileToDirectory(file, destFolder);
		}

		System.out.println("Delete source folder(y/n)?");
		String answ = Consolse.readLine();
		if ("y".equalsIgnoreCase(answ)) {
			System.out.println("Deleting...");
			FileUtils.deleteDirectory(sourceFolder);
			System.out.println("Deleted source folder");
		}
		System.out.println("Done");
	}
}
